using Core;
using Modules.Audio;
using Modules.SoundEffect;
using UnityEngine;
using Utils.Singleton;

namespace Toolkit.AudioExtend
{
    public class AudioManager : CommonSingleton<AudioManager>
    {
        public static AudioStore AudioStore { private set; get; }
        private AudioPlayer _audioPlayer;
        private SoundEffectPlayer _soundEffectPlayer;

        static AudioManager()
        {
            AudioStore = Resources.Load<AudioStore>("AudioStore");
        }

        public AudioPlayer AudioPlayer
        {
            get
            {
                if (_audioPlayer == null)
                {
                    _audioPlayer = GameSubsystem.Find<AudioPlayer>();
                }

                return _audioPlayer;
            }
        }

        public SoundEffectPlayer SoundEffectPlayer
        {
            get
            {
                if (_soundEffectPlayer == null)
                    _soundEffectPlayer = GameSubsystem.Find<SoundEffectPlayer>();

                return _soundEffectPlayer;
            }
        }
    }
}